import { mapState, mapMutations } from 'vuex'
export default {
	name: 'login',
	data() {
		return {
			userName:'',
			userPwd:'',
		}
	},
	computed: {
		...mapState([
			'token'
		]),
	},
	methods: {
		...mapMutations([
			'TOKEN'
		]),
		login(){
			this.$axios({
					method: 'post',
					url: '/user/login?temp='+Math.random(),
					data:{userName:this.userName,userPwd:this.userPwd}
				})
				.then((res) => {	
					if(res.data.status=="1001"){
						alert("登录成功")
						this.TOKEN(true);
						this.$router.push({
							path: '/msgBoard'
						});						
					}else{
						alert("用户名密码有误")
					}
				})
				.catch((error) => {
					alert("请求异常")
				})
		}
	},
	components: {

	},
	created() {
		document.title = "管理员登录";
		
	}
}